﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace WebApp.Web
{
    public class NSecRun1ScheduleItem : COM.Web.IScheduleTask
    {
        private Func<DateTime?> action;
        public NSecRun1ScheduleItem(int second, Func<DateTime?> action)
        {
            this.nextTaskDateTime = DateTime.Now.Add(new TimeSpan(0, 0, second));
            this.action = action;
        }

        private DateTime? nextTaskDateTime;
        public DateTime? NextTaskDateTime
        {
            get
            {
                return this.nextTaskDateTime;
            }
        }

        public DateTime? ExecuteTask()
        {
            if (this.action != null)
                return (this.nextTaskDateTime = this.action());

            return null;
        }

    }
}